//
//  WHSelectAddressCell.m
//  SquirrelCourier
//
//  Created by 邓伟浩 on 2019/1/4.
//  Copyright © 2019 邓伟浩. All rights reserved.
//

#import "WHSelectAddressCell.h"

@interface WHSelectAddressCell ()

@property (nonatomic, strong) UILabel *tipsLabel;
@property (nonatomic, strong) UILabel *addressLabel;

@end

@implementation WHSelectAddressCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setUpSelectAddressUI];
    }
    return self;
}

- (void)setUpSelectAddressUI {
    [self.contentView addSubview:({
        _tipsLabel = [[UILabel alloc] init];
        _tipsLabel.textColor = CFontTitleBlackColor;
        _tipsLabel.font = SYSTEMFONT(kRealwidth(16));
        _tipsLabel.text = @"门店名称";
        _tipsLabel;
    })];
    [_tipsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView.mas_left).offset(kRealwidth(15));
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.height.mas_equalTo(kRealwidth(16));
    }];
    [_tipsLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    [_tipsLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    
    [self.contentView addSubview:({
        _rightTipsImageView = [[UIImageView alloc] init];
        _rightTipsImageView.contentMode = UIViewContentModeScaleAspectFit;
        _rightTipsImageView.image = IMAGE_NAMED(@"icon_tips_right");
        _rightTipsImageView;
    })];
    
    [_rightTipsImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.contentView.mas_right).offset(-kRealwidth(15));
        make.width.mas_equalTo(kRealwidth(8));
        make.height.mas_equalTo(kRealwidth(14));
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
    }];
    
    [self.contentView addSubview:({
        _addressLabel = [[UILabel alloc] init];
        _addressLabel.textColor = CFontContentLightGrayColor;
        _addressLabel.font = SYSTEMFONT(kRealwidth(15));
        _addressLabel.adjustsFontSizeToFitWidth = YES;
        _addressLabel.text = @"请输入门店名称";
        _addressLabel;
    })];
    [_addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_tipsLabel.mas_right).offset(kRealwidth(15));
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.height.mas_equalTo(kRealwidth(15));
        make.right.mas_equalTo(_rightTipsImageView.mas_left).offset(-kRealwidth(15));
    }];
}

- (void)setAddressName:(NSString *)addressName {
    _addressName = addressName;
    
    if (ValidStr(addressName)) {
        _addressLabel.text = addressName;
        _addressLabel.textColor = CFontContentGrayColor;
    } else {
        _addressLabel.text = @"请输入门店名称";
        _addressLabel.textColor = CFontContentLightGrayColor;
    }
    
}

@end
